﻿using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using PLC.Domain.Entity;

namespace PLC.Infrastructure.DbContext.Config;

public class DeviceStatusConfig:IEntityTypeConfiguration<DeviceStatus>
{
    public void Configure(EntityTypeBuilder<DeviceStatus> builder)
    {
        builder.ToTable("tb_data_devicestatus");
        builder.HasKey(p => p.Id);
        builder.Property(p => p.Id).ValueGeneratedNever();
        builder.HasIndex(p => p.DeviceId);
        builder.Property(p => p.DeviceId).IsRequired();
        builder.Property(p => p.Register).HasMaxLength(128).IsRequired();
        builder.Property(p => p.DataType).IsRequired();
        builder.Property(p => p.RegisterValue).HasMaxLength(128).IsRequired();
        builder.Property(p => p.Description).HasMaxLength(128).IsRequired();
    }
}